<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增商品</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
 <!-- <link rel="stylesheet" href="https://cdn.zhsmjxc.com/CDN/Static-webapp/jsmin/style.css?version=5.7.0.201901051730" type="text/css">-->
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/js/laypage/skin/laypage.css">
    <link rel="stylesheet" type="text/css" href="/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" href="/lib/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="/lib/layui/layui.js"></script>
    <script type="text/javascript" src="/js/vue/vue.min.js"></script>
    <script src="/jquery/jquery-3.3.1.js"></script>
    <script src="/js/laypage/laypage.js" charset="utf-8"></script>
    <script src="/js/layer/layer.js" charset="utf-8"></script>
</head>
<body>
<div class="container">
    <form id="addCommdityForm">
    <br>
           <b>基本信息</b>
            <hr style="height:1px;background-color: #2E2D3C"/>
                条形码&nbsp; <input type="text" name="tiaoxingma" id="tiaoxingma" placeholder="选填，扫描或录入条形码"><br><br>
            <span class="c-red">*</span> 编号&nbsp;&nbsp;&nbsp;<input type="text" name="bianhao" id="bianhao"><br><br>
            <span class="c-red">*</span>名称&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="mingcheng" id="mingcheng" ><br><br>
        分类 &nbsp;&nbsp;&nbsp;
        <select id="comclass" name="comclass" class="select"  style="width: 100px">
         </select>
           <br><br>

            <tr id="singleUnitTr">
                <td width="100" align="right" class="font14">
                    <span class="c-red">*</span>单位&nbsp;&nbsp;&nbsp;
                    <select style="width: 100px" name="danwei" id="sadanwei"  onfocus="selectFocus(this)">
                        <option value="" onclick="selectClick(this)">包</option>
                        <option value="" onclick="selectClick(this)">杯</option>
                        <option value="" onclick="selectClick(this)">袋</option>
                        <option value="" onclick="selectClick(this)">个</option>
                        <option value="" onclick="selectClick(this)">公斤</option>
                        <option value="" onclick="selectClick(this)">罐</option>
                        <option value="" onclick="selectClick(this)">升</option>
                        <option value="" onclick="selectClick(this)">件</option>
                        <option value="" onclick="selectClick(this)">斤</option>
                        <option value="" onclick="selectClick(this)">克</option>
                        <option value="" onclick="selectClick(this)">排</option>
                        <option value="" onclick="selectClick(this)">瓶</option>
                        <option value="" onclick="selectClick(this)">提</option>
                        <option value="" onclick="selectClick(this)">箱</option>
                        <option value="" onclick="selectClick(this)">支</option>
                    </select>
            </tr><br><br>
             规格&nbsp;&nbsp;&nbsp;<input type="text" id="guige" name="guige" placeholder="选填，如'红色长款'"><br><br>
       <tr class="free">
            <td id="multPropertiesTd">
                <input type="checkbox" id="propertyid" name="propertyname" onclick="enableProperty(this)"><b>多属性支持</b>
            </td>
        </tr>
        <br>
         <div class="height10">
          <div id="multPropertyDiv" style="display:none">
            品&nbsp;&nbsp;&nbsp;牌&nbsp;&nbsp;&nbsp;<select id="pinpai" name="pinpai" style="width: 200px">
                <option></option>
            </select>
              <a href="/basicdata/commodity-list/getcommdityfenye" style="margin-left: 800px">属性设置</a><br><br>
              产&nbsp;&nbsp;&nbsp;地&nbsp;&nbsp;&nbsp;<select id="chandi" name="chandi" style="width: 200px">
              <option></option>
          </select><br><br>
              自定义属性1&nbsp;&nbsp;&nbsp;<select id="zidingyione" name="zidingyione" style="width: 200px">
              <option></option>
          </select><br><br>
              自定义属性2&nbsp;&nbsp;&nbsp;<select id="zidingyitwo" name="zidingyitwo" style="width: 200px">
              <option></option>
          </select><br><br>
              自定义属性3&nbsp;&nbsp;&nbsp;<select id="zidingyithree" name="zidingyithree" style="width: 200px">
              <option></option>
          </select><br><br>
          </div>
             <hr>
             <div class="formTitle" style="position: static !important;display: block">
                    价格管理
                    <hr style="height:1px;background-color: #2E2D3C"/>
                    <table  border="2" align="center">
                        <thead>
                        <tr>
                            <th width="100" rowspan="2" style="text-align: center" height="50"><b><span style="font-size: 14px">价格类别</span></b></th>
                            <th width="100" height="50"></th>
                            <th width="600" style="text-align: center" height="50"><b><span style="font-size: 14px">价格</span></b></th>
                        </tr>
                        </thead>
                        <tr>
                            <td width="300"  rowspan="3" style="text-align: center" height="50"><b><span style="font-size: 14px">销售</span></b></td>
                            <td width="100" style="text-align: center" height="50"><b><span style="font-size: 14px">零售价</span></b></td>
                            <td width="600" style="text-align: center" height="50"><input type="text" size="25" id="comlingshoujia" style="text-align: center"></td>

                        </tr>
                        <tr>
                            <td width="100" height="50" style="text-align: center"><b><span style="font-size: 14px">最低零售价</span></b></td>
                            <td width="600" height="50" style="text-align: center"><input type="text" size="25" id="comzuilingshoujia" style="text-align: center"></td>
                        </tr>
                        <tr>
                            <td width="100" height="50" style="text-align: center"><b><span style="font-size: 14px">批发价</span></b></td>
                            <td width="600" height="50" style="text-align: center"><input type="text" size="25" id="compifajia" style="text-align: center"></td>
                        </tr>
                        <tr>
                            <td width="100" height="50" style="text-align: center"><b><span style="font-size: 14px">进货</span></b></td>
                            <td width="100" height="50" style="text-align: center"><b><span style="font-size: 14px">参考进货价</span></b></td>
                            <td width="600" height="50" style="text-align: center"><input type="text" size="25" id="cankaojinhuojia" style="text-align: center"></td>
                        </tr>
                    </table>
                </div>
             <div class="formTitle" style="position: static !important;">
            <hr>
            库存预警
            <div class="fr font12" >
                <td>
                    <input class="free" id="kucunyujing" name="" type="checkbox" value="" onclick="enableMultiUnit(this)">&nbsp;&nbsp;
                    <label class="free" for="kucunyujing">所有仓库预警值相同</label>&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </div>
            <hr style="height:1px;background-color: #2E2D3C"/>
        </div>
             <div  id="kucunlaing" style="display: none">
          最低库存量&nbsp;&nbsp;&nbsp;<input type="text" size="15"  id="zuidikucun" name="zuidikucun"><br><br>
            最高库存量&nbsp;&nbsp;&nbsp;<input type="text" size="15" id="zuigaokucun" name="zuigaokucun">
        </div>
            <div id="cangku" style="display: block" >
            <table border="1px black solid" align="center">
                <tr style="width: auto;height: auto">
                    <td width="300" height="50" style="text-align: center"><b><span style="font-size: 14px">仓库</span></b></td>
                    <td width="300" height="50" style="text-align: center" ><b><span style="font-size: 14px">最低库存量</span></b></td>
                    <td width="300" height="50" style="text-align: center"><b><span style="font-size: 14px">最高库存量</span></b></td>
                </tr>
                <tr>
                    <td width="300"  height="50" style="text-align: center"><b><span style="font-size: 14px">
                        <select id="warehouse" name="warehouse" class="select"  style="width: 100px"></select>
                    </span></b></td>
                    <td style="text-align: center" height="50" ><input type="text" size="25" id="comzuidikucun" name="czuidikc" style="text-align: center"> </td>
                    <td style="text-align: center"  height="50" ><input type="text" size="25" id="comzuigaokucun" name="czuigaok" style="text-align: center"></td>
                </tr>
            </table>
        </div>
             <hr>
             <div class="formTitle"><b><span style="font-size: 18px">其他</span></b></div>
             <hr>
          <table width="100%" border="0" cellspacing="0" cellpadding="8">
            <div class="form-group">
                <label for="remark"><b><span style="font-size: 18px">备注：</span></b></label>
                <textarea class="form-control" id="remark" name="remark" rows="4" cols="150" ></textarea>
            </div>
         </table>
            </div>
        <div class="form-group"  style="margin-top: 10px">
            <button type="button" id="SaveBtn" class="btn btn-success">提交</button>
            <button type="button" id="CancelBtn" class="btn btn-default">取消</button>
        </div>
    </form>
</div>
<script>
    var app = new Vue({
        el : '#app',
        data : {
            result : []
        }
    });
  var addCommity=function () {
      var clunit=$("#sadanwei").find("option:selected").text();
      var clid=$("#comclass").find("option:selected").val();
      var wmid=$("#warehouse").find("option:selected").val();
        $.ajax({
            type:'POST',
            dataType:'json',
            url:"/basicdata/commodity-list/addpage",
            data:{
                clScan:$("#tiaoxingma").val(),
                clNumber:$("#bianhao").val(),
                clName:$("#mingcheng").val(),
                ccId:clid,
                clUnit:clunit,
                clSpec:$("#guige").val(),
                clPurPrice:$("#cankaojinhuojia").val(),
                clWhoPrice:$("#compifajia").val(),
                clTagPrise:$("#comlingshoujia").val(),
                wmId:wmid,
                clMinLingPrice:$("#comzuilingshoujia").val(),
                clMinStock:$("#comzuidikucun").val(),
                clMAxStock:$("#comzuigaokucun").val(),
            },
            success:function () {
                alert(clunit);
                $("#CancelBtn").click();
            }
        });
    }
   $("#SaveBtn").click(function () {
        addCommity();
    });
  $("#CancelBtn").click(function () {
        var index=parent.layer.getFrameIndex(window.name);
        parent.getCommdityPageList();
        parent.layer.close(index);
    });
    /**
     * 实现select的滚动条的script
     * @param that
     */
    window.selectFocus = function(that) {
        $(that).attr("size", 5);
    };
    window.selectClick = function(that) {
        $(that).parent().removeAttr("size");
        $(that).parent().blur();
        $(that).parent().children("[selected='selected']").removeAttr("selected");
        $(that).attr("selected", "");
    };
/*  属性设置的script*/
    function enableProperty(obj){
        var checks=document.getElementById("multPropertyDiv");
        if (obj.checked){
            checks.style.display="block";
        } else{
            checks.style.display="none";
        }
    }
  /*仓库管理*/
  function enableMultiUnit(obj){
      var cangku=document.getElementById("cangku");
      var kucunlaing=document.getElementById("kucunlaing");
        if (obj.checked){
            cangku.style.display="none";
            kucunlaing.style.display="block";
        }else{
            cangku.style.display="block";
            kucunlaing.style.display="none";
        }
  }
  /*分类管理*/
  var property=function () {
        window.location.href="/basicdata/commodity-list/getcommdityfenye";
    }
    //商品分类
  var getCommclassList = function() {
      $.ajax({
          type : "POST",
          dataType : "json",
          url : "/basicdata/commclass/queryList",
         success:function(msg) {
                  var html="<option value=''>请选择</option>";
                  for(var i=0;i<msg.commclass.length;i++){
                      html += "<option value= '"+msg.commclass[i].id+"'>"+msg.commclass[i].ccDefault+"</option>";
              }
             $("#comclass").html('').append(html);
          }
      });
  }
  getCommclassList();
  /*仓库分类*/
    var getWarehouseList = function() {
        $.ajax({
            type : "POST",
            dataType : "json",
            url : "/basicdata/warehouse-management/selectware",
            success:function(msg) {
                var html="<option value=''>请选择</option>";
                for(var i=0;i<msg.warelist.length;i++){
                    html += "<option value= '"+msg.warelist[i].id+"'>"+msg.warelist[i].wmName+"</option>";
                }
                $("#warehouse").html('').append(html);
            }
        });
    }
    getWarehouseList();

</script>
</body>
</html>